package day04;

import java.util.Random;
import java.util.Scanner;

//
public class Guessing {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = (int)(Math.random()*1000+1);//1到1000的整数
        System.out.println(num);//作弊

        System.out.println("猜出1-1000的随机数");
        int guess;
        do{
            guess = scan.nextInt();//第1要素+第2要素
            if (guess > num) {
                System.out.println("猜大了");
            }else if (guess < num){
                System.out.println("猜小了");
            }else {
                System.out.println("恭喜您猜对啦!");
            }
        }while (guess!=num);//第2个要素








        /*
            Math.random()------0.0到0.9999999...
        ==> *1000--------------0.0到999.99999...
        ==> +1-----------------1.0到1000.9999...
        ==> 强转(int)-----------1到999
         */

/*
        Scanner scan = new Scanner(System.in);
        int num = (int)(Math.random()*1000+1);//1到1000的整数
        System.out.println(num);//作弊

        System.out.println("猜出1-1000的随机数");
        int guess = scan.nextInt();
        while (guess!=num){
            if (guess > num) {
                System.out.println("猜大了");
                guess = scan.nextInt();
            }else {
                System.out.println("猜小了");
                guess = scan.nextInt();
            }
        }
        System.out.println("恭喜您猜对啦");

 */




/*
        Scanner scan = new Scanner(System.in);//键盘录入
        Random random = new Random();//随机生成
        int num = random.nextInt(100);//随机生成1-100的整数

        System.out.println("猜数游戏:1-100的整数");
        int guess = scan.nextInt();
        while (guess!=num){
            if (guess > num) {
                System.out.println("猜大了");
                guess = scan.nextInt();
            }else {
                System.out.println("猜小了");
                guess = scan.nextInt();
            }
        }
        System.out.println("恭喜您猜对啦");
 */
    }
}
